<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript" src="/lookdom/js/jquery-1.8.0.js" charset="UTF-8"></script>
<script type="text/javascript">

	var isLogin;
	
	function goLogin() {
		var id = $("#id").val();
		var pw = $("#pw").val();
		var url = "/lookdom/login2.do?" + "id=" + id +  "&pw=" + pw;
		
		$.ajax({
			type	: "POST",
			url		: url,
			dataType: "json",
			data	: "",
			success	: function(data) {
				isLogin = data.isLogin;
				if(isLogin) {
					alert('로그인 성공');
				} else {
					alert('패스워드가 틀렸습니다.');
				}
			} ,
	         
	         error: function(xhr, status, error) {
	        	 alert('error-'+error); 
	         }
		}); 
	}
	
	function goIndex() {
		var url = "/lookdom/index.do";
		$(location).attr('href',url); 
	}
</script>

</head>
<body>
	<input type="button" onclick="goIndex();" value="인덱스페이지"> <br><br>
	<table>
		<tr>
			<td>아이디 </td>
			<td>
				<input type="text" name="id" id="id"  size="10">
			</td>
		</tr>
		<tr>
			<td>패스워드 </td>
			<td>
				<input type="text" name="pw" id="pw"  size="10">
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="button" value="로그인" onclick="goLogin();"> 
			</td>
		</tr>
	</table>
</body>
</html>